package jifenbao.com.widget.ActionBar;

import android.content.Context;
import android.content.res.ColorStateList;
import android.content.res.TypedArray;
import android.graphics.Color;
import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.DrawableContainer;
import android.util.AttributeSet;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import java.text.AttributedCharacterIterator;

import jifenbao.com.jifenbao.R;

/**
 * Created by longteng on 2016-6-1.
 */
public class BaseTitleBar extends BaseHeaderView{
    private String titleText,titleText2;
    private TextView titleView,titleView2;
    private int titleTextColor,titleTextColor2;
    private float titleTextSize,titleTextSize2;
    public BaseTitleBar(Context context) {
        super(context);
    }

    public BaseTitleBar(Context context, AttributeSet attrs) {
        super(context, attrs);
    }

    public BaseTitleBar(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
    }

    protected void getAttrs(AttributeSet attrs){
        super.getAttrs(attrs);
        TypedArray ta = context.obtainStyledAttributes(attrs, R.styleable.BaseTitleBar);
        titleText = ta.getString(R.styleable.BaseTitleBar_titleText);
        titleTextColor = ta.getColor(R.styleable.BaseTitleBar_titleTextColour, Color.WHITE);
        titleTextSize = ta.getDimension(R.styleable.BaseTitleBar_titleTextSize,40);

        titleText2 = ta.getString(R.styleable.BaseTitleBar_titleText2);
        titleTextColor2 = ta.getColor(R.styleable.BaseTitleBar_titleTextColour2, Color.WHITE);
        titleTextSize2 = ta.getDimension(R.styleable.BaseTitleBar_titleTextSize2,40);
        ta.recycle();
    }

    public void Searchview(){
        super.Searchview();
        titleView = new TextView(context);
        titleView2 = new TextView(context);
    }

    public void startView(){
        super.startView();
        titleView.setText(titleText);
        titleView.setTextColor(titleTextColor);
        titleView.setTextSize(titleTextSize);

        titleView2.setText(titleText2);
        titleView2.setTextColor(titleTextColor2);
        titleView2.setTextSize(titleTextSize2);
    }

    public void setTitleText(String str){
        titleView.setText(str == null ? "" : str);
    }

    @Override
    public View getLeftView() {
        return titleView2;
    }

    @Override
    public View getCenterView() {
        return titleView;
    }

    @Override
    public View getRightView() {
        return null;
    }
}
